package com.ch2;

import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by wangjing on 2018/7/20.
 */
@RestController
public class DiscoveryController {
    private final Logger logger = Logger.getLogger(getClass());
//    @Autowired
//    private DiscoveryClient client;

    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String index(HttpServletRequest request){
        logger.info("===<call trace,TraceId="+request.getHeader("X-B3-TraceId")+",SpanId="+request.getHeader("X-B3-SpanId"));
        return "hello";
    }


    @RequestMapping(value = "/hello_name",method = RequestMethod.GET)
    public String index(@RequestParam String name){
        return "hello---"+name;
    }

    @RequestMapping(value = "/hello_age",method = RequestMethod.GET)
    public String index(@RequestHeader String name,@RequestHeader Integer age){
        return "hello---"+name+",age = " +age;
    }


    @RequestMapping(value = "/hello_user",method = RequestMethod.POST)
    public String index(@RequestBody User user){
        return "hello---"+user.getName()+","+user.getAge();
    }
}
